// 定义表头数据
const tHead = {
  'main-page':[{
    prop: 'id',
    name: '编号',
    showTip: true
  }, {
    prop: 'title',
    name: '名称',
    showTip: true
  }, {
    prop: 'price',
    name: '价格',
    showTip: true
  }]
}

// 定义操作列的按钮（如有）
const tOpera = {
  'main-page':[{
    label: '上架',
    width: '50',
    fixed: 'right',
    list: [{
      type: 'switch',
      active: 1,
      inactive: 0,
      tag: 'onUse'
    }] }, {
    label: '操作',
    width: '80',
    fixed: 'right',
    list: [{
      type: 'btn',
      label: '新增',
      value: 'add',
      color: '#2F51FF'
    },{
      type: 'btn',
      label: '删除',
      value: 'delete',
      color: '#E41212'
    }] 
  }]
}

const getTHead = (id = null, param = null) => {
  let head = [];
  if (id && id !== '') {
    head = jsonClone(tHead[id]);
  }
  return head;
};

const getTOpera = (id = null, param = null) => {
  let operaList = [];
  if (id && id !== '') {
    operaList = jsonClone(tOpera[id]);
  }
  return operaList;
};

const jsonClone = (param) => {
  if (!param && param !== 0) return undefined;
  return JSON.parse(JSON.stringify(param));
}

export {
  tHead,
  getTHead,
  tOpera,
  getTOpera
};